set RECV_LISTEN(QUIT) m_quit

proc m_quit {chid raw parent me} {
	global CHANS_$chid
	regexp {:([^!]+)![^ ]+ QUIT :(.*)} $raw -> nick reason
	set chans [$parent tabs]
	foreach chan $chans {
		set userlist [$chan.users get 0 end]
		set idx 0
		foreach user $userlist {
			set n_user [string map {
				"~" ""
				"&" ""
				"@" ""
				"!" ""
				"+" ""
				"%" ""
			} $user]
			if { "$nick" == "$n_user" } {
				output $chan "<- $nick has quit IRC ($reason)\n" grey39
				$chan.users delete $idx
			}
			incr idx
		}
	}
}
